/**
 * Mock数据管理模块
 * 
 * 功能说明：
 * 1. 提供完整的模拟数据，支持前端开发和测试
 * 2. 包含用户端和管理端的所有数据结构
 * 3. 提供工具函数模拟API响应和分页
 * 
 * 数据模块：
 * - 用户信息：个人基本信息和健康档案
 * - 套餐管理：健康套餐、护理套餐等
 * - 健康数据：生理指标、用药记录、健康趋势
 * - 生活管理：日程安排、提醒事项、生活记录
 * - 数据分析：健康评估、活动分析、睡眠分析
 * - 人工服务：服务申请、工作人员信息
 * - 安全管理：登录记录、紧急联系人、隐私设置
 * - 公告管理：系统通知、功能更新、服务公告
 * - 后台管理：病例记录、医疗档案、外出服务
 * 
 * 使用方式：
 * import { mockUserInfo, mockHealthData } from '@/utils/mockData'
 */

// ==================== 用户端数据 ====================

/**
 * 用户基本信息
 * 包含个人资料、联系方式、健康档案等
 */
export const mockUserInfo = {
  id: 1,
  name: '张大爷',
  gender: '男',
  age: 68,
  idCard: '110101195501011234',
  phone: '13800138000',
  emergencyContact: '李女士',
  emergencyPhone: '13900139000',
  bloodType: 'A型',
  address: '北京市朝阳区xxx小区xxx号楼xxx室',
  allergies: '青霉素过敏',
  chronicDiseases: '高血压、糖尿病',
  avatar: '/default-avatar.png',
  createTime: '2023-01-15',
  lastLoginTime: '2024-01-20 10:30:00'
}

/**
 * 套餐管理数据
 * 包含各种健康服务套餐的信息
 */
export const mockCombos = [
  {
    id: 1,
    name: '基础健康套餐',
    type: 'health',
    duration: 30,
    price: 299,
    startDate: '2024-01-01',
    endDate: '2024-01-31',
    status: 'active',
    progress: 75,
    description: '包含基础健康监测、用药提醒等服务',
    services: ['健康监测', '用药提醒', '生活记录']
  },
  {
    id: 2,
    name: '高级护理套餐',
    type: 'care',
    duration: 90,
    price: 899,
    startDate: '2024-01-15',
    endDate: '2024-04-15',
    status: 'active',
    progress: 45,
    description: '专业护理人员定期上门服务',
    services: ['专业护理', '健康评估', '紧急救助']
  },
  {
    id: 3,
    name: '生活助理套餐',
    type: 'life',
    duration: 60,
    price: 599,
    startDate: '2023-12-01',
    endDate: '2024-01-30',
    status: 'expired',
    progress: 100,
    description: '日常生活辅助和代办服务',
    services: ['生活辅助', '代办服务', '陪伴聊天']
  }
]

/**
 * 健康管理数据
 * 包含生理指标、健康记录、用药信息等
 */
export const mockHealthData = {
  // 健康概览
  overview: {
    bloodPressure: { systolic: 135, diastolic: 85, time: '2024-01-20 08:00' },
    bloodSugar: { value: 6.8, time: '2024-01-20 07:30' },
    heartRate: { value: 78, time: '2024-01-20 08:15' },
    temperature: { value: 36.5, time: '2024-01-20 08:00' }
  },
  
  // 健康记录
  records: [
    {
      id: 1,
      date: '2024-01-20',
      time: '08:00',
      type: 'bloodPressure',
      systolic: 135,
      diastolic: 85,
      note: '早晨测量，感觉正常'
    },
    {
      id: 2,
      date: '2024-01-20',
      time: '07:30',
      type: 'bloodSugar',
      value: 6.8,
      note: '空腹血糖'
    },
    {
      id: 3,
      date: '2024-01-19',
      time: '20:00',
      type: 'weight',
      value: 70.5,
      note: '晚饭后测量'
    }
  ],
  
  // 用药提醒
  medications: [
    {
      id: 1,
      name: '降压药',
      dosage: '1片',
      frequency: '每日2次',
      times: ['08:00', '20:00'],
      startDate: '2024-01-01',
      endDate: '2024-03-01',
      note: '饭后服用'
    },
    {
      id: 2,
      name: '降糖药',
      dosage: '0.5片',
      frequency: '每日1次',
      times: ['07:30'],
      startDate: '2024-01-01',
      endDate: '2024-06-01',
      note: '空腹服用'
    }
  ]
}

/**
 * 生活管理数据
 * 包含日程安排、提醒事项、生活记录等
 */
export const mockLifeData = {
  // 日程安排
  schedules: [
    {
      id: 1,
      title: '体检',
      date: '2024-01-25',
      time: '09:00',
      type: 'medical',
      location: '人民医院',
      note: '年度体检，需要空腹'
    },
    {
      id: 2,
      title: '买菜',
      date: '2024-01-21',
      time: '08:00',
      type: 'daily',
      location: '小区菜市场',
      note: '购买一周的蔬菜'
    },
    {
      id: 3,
      title: '散步',
      date: '2024-01-20',
      time: '18:00',
      type: 'exercise',
      location: '小区花园',
      note: '晚饭后散步30分钟'
    }
  ],
  
  // 生活提醒
  reminders: [
    {
      id: 1,
      title: '喝水提醒',
      time: '每2小时',
      type: 'health',
      enabled: true
    },
    {
      id: 2,
      title: '测血压',
      time: '每日08:00',
      type: 'health',
      enabled: true
    },
    {
      id: 3,
      title: '锻炼提醒',
      time: '每日18:00',
      type: 'exercise',
      enabled: false
    }
  ],
  
  // 生活记录
  records: [
    {
      id: 1,
      date: '2024-01-20',
      type: 'mood',
      content: '今天心情不错，天气晴朗',
      rating: 4
    },
    {
      id: 2,
      date: '2024-01-19',
      type: 'sleep',
      content: '睡眠质量良好，7小时',
      rating: 5
    },
    {
      id: 3,
      date: '2024-01-18',
      type: 'exercise',
      content: '散步30分钟，感觉很好',
      rating: 4
    }
  ]
}

/**
 * 数据分析模块
 * 包含健康趋势、活动分析、睡眠分析等
 */
export const mockAnalyticsData = {
  // 数据概览
  overview: {
    healthIndex: 85,
    activityLevel: 72,
    sleepQuality: 88,
    moodIndex: 90
  },
  
  // 健康趋势数据
  healthTrends: {
    bloodPressure: [
      { date: '2024-01-15', systolic: 140, diastolic: 90 },
      { date: '2024-01-16', systolic: 138, diastolic: 88 },
      { date: '2024-01-17', systolic: 135, diastolic: 85 },
      { date: '2024-01-18', systolic: 132, diastolic: 82 },
      { date: '2024-01-19', systolic: 130, diastolic: 80 },
      { date: '2024-01-20', systolic: 135, diastolic: 85 }
    ],
    bloodSugar: [
      { date: '2024-01-15', value: 7.2 },
      { date: '2024-01-16', value: 6.9 },
      { date: '2024-01-17', value: 6.5 },
      { date: '2024-01-18', value: 6.8 },
      { date: '2024-01-19', value: 6.6 },
      { date: '2024-01-20', value: 6.8 }
    ],
    heartRate: [
      { date: '2024-01-15', value: 82 },
      { date: '2024-01-16', value: 79 },
      { date: '2024-01-17', value: 76 },
      { date: '2024-01-18', value: 78 },
      { date: '2024-01-19', value: 75 },
      { date: '2024-01-20', value: 78 }
    ],
    weight: [
      { date: '2024-01-15', value: 71.2 },
      { date: '2024-01-16', value: 71.0 },
      { date: '2024-01-17', value: 70.8 },
      { date: '2024-01-18', value: 70.6 },
      { date: '2024-01-19', value: 70.5 },
      { date: '2024-01-20', value: 70.5 }
    ]
  },
  
  // 健康评估报告
  healthAssessment: {
    score: 85,
    level: '良好',
    suggestions: [
      '继续保持规律的作息时间',
      '适当增加有氧运动',
      '注意控制盐分摄入',
      '定期监测血压和血糖'
    ],
    riskFactors: [
      { name: '高血压风险', level: '中等', description: '血压偶有波动，需要持续监测' },
      { name: '糖尿病风险', level: '低', description: '血糖控制良好' }
    ]
  },
  
  // 活动分析
  activityAnalysis: {
    steps: [
      { date: '2024-01-15', value: 5200 },
      { date: '2024-01-16', value: 6800 },
      { date: '2024-01-17', value: 4500 },
      { date: '2024-01-18', value: 7200 },
      { date: '2024-01-19', value: 5800 },
      { date: '2024-01-20', value: 6200 }
    ],
    exerciseDuration: [
      { date: '2024-01-15', value: 30 },
      { date: '2024-01-16', value: 45 },
      { date: '2024-01-17', value: 20 },
      { date: '2024-01-18', value: 60 },
      { date: '2024-01-19', value: 35 },
      { date: '2024-01-20', value: 40 }
    ],
    calories: [
      { date: '2024-01-15', value: 180 },
      { date: '2024-01-16', value: 240 },
      { date: '2024-01-17', value: 120 },
      { date: '2024-01-18', value: 300 },
      { date: '2024-01-19', value: 200 },
      { date: '2024-01-20', value: 220 }
    ]
  },
  
  // 睡眠分析
  sleepAnalysis: {
    overview: {
      averageDuration: 7.2,
      averageQuality: 4.1,
      sleepEfficiency: 88
    },
    sleepData: [
      { date: '2024-01-15', duration: 7.5, quality: 4, bedTime: '22:30', wakeTime: '06:00' },
      { date: '2024-01-16', duration: 6.8, quality: 3, bedTime: '23:00', wakeTime: '05:48' },
      { date: '2024-01-17', duration: 7.2, quality: 4, bedTime: '22:15', wakeTime: '05:27' },
      { date: '2024-01-18', duration: 7.8, quality: 5, bedTime: '22:00', wakeTime: '05:48' },
      { date: '2024-01-19', duration: 6.5, quality: 4, bedTime: '23:30', wakeTime: '06:00' },
      { date: '2024-01-20', duration: 7.5, quality: 4, bedTime: '22:20', wakeTime: '05:50' }
    ],
    sleepStages: {
      deep: 25,
      light: 55,
      rem: 20
    },
    tips: [
      '保持规律的睡眠时间',
      '睡前避免使用电子设备',
      '创造舒适的睡眠环境',
      '适当的晚间运动有助于睡眠'
    ]
  }
}

/**
 * 人工服务数据
 * 包含服务申请、服务类型、工作人员信息等
 */
export const mockArtificialData = {
  // 服务申请
  applications: [
    {
      id: 'ART001',
      serviceType: 'housekeeping',
      status: 'completed',
      appointmentTime: '2024-01-18 14:00',
      address: '北京市朝阳区xxx小区',
      description: '家庭清洁服务',
      price: 80,
      workerName: '张阿姨',
      workerPhone: '13900139001',
      rating: 5,
      comment: '服务很好，很满意',
      createTime: '2024-01-15 10:30',
      completeTime: '2024-01-18 16:30'
    },
    {
      id: 'ART002',
      serviceType: 'care',
      status: 'processing',
      appointmentTime: '2024-01-22 09:00',
      address: '人民医院',
      description: '医院陪护服务',
      price: 120,
      workerName: '王护士',
      workerPhone: '13900139002',
      createTime: '2024-01-20 16:20'
    },
    {
      id: 'ART003',
      serviceType: 'errand',
      status: 'pending',
      appointmentTime: '2024-01-23 10:00',
      address: '社区服务中心',
      description: '代办证件',
      price: 50,
      createTime: '2024-01-21 09:15'
    }
  ],
  
  // 服务类型
  serviceTypes: [
    { value: 'housekeeping', label: '家政服务', price: 80, description: '家庭清洁、整理等服务' },
    { value: 'care', label: '陪护服务', price: 120, description: '医院陪护、居家照料等' },
    { value: 'errand', label: '代办服务', price: 50, description: '代办各类证件、手续等' },
    { value: 'transport', label: '接送服务', price: 100, description: '医院接送、购物接送等' }
  ]
}

/**
 * 安全管理数据
 * 包含登录记录、紧急联系人、隐私设置等
 */
export const mockSecurityData = {
  // 登录记录
  loginRecords: [
    {
      id: 1,
      loginTime: '2024-01-20 10:30:00',
      ip: '192.168.1.100',
      device: 'Windows PC',
      location: '北京市朝阳区',
      status: 'success'
    },
    {
      id: 2,
      loginTime: '2024-01-19 15:20:00',
      ip: '192.168.1.100',
      device: 'Windows PC',
      location: '北京市朝阳区',
      status: 'success'
    },
    {
      id: 3,
      loginTime: '2024-01-18 09:15:00',
      ip: '192.168.1.100',
      device: 'Windows PC',
      location: '北京市朝阳区',
      status: 'success'
    }
  ],
  
  // 紧急联系人
  emergencyContacts: [
    {
      id: 1,
      name: '李女士',
      relationship: '女儿',
      phone: '13900139000',
      address: '北京市海淀区xxx小区',
      isPrimary: true
    },
    {
      id: 2,
      name: '张先生',
      relationship: '儿子',
      phone: '13800138001',
      address: '北京市西城区xxx小区',
      isPrimary: false
    }
  ],
  
  // 安全设置
  securitySettings: {
    profileVisibility: 'friends',
    healthDataSharing: true,
    locationSharing: false,
    pushNotifications: true,
    twoFactorAuth: false
  }
}

/**
 * 公告管理数据
 * 包含系统通知、功能更新、服务公告等
 */
export const mockAnnouncementData = {
  // 公告列表
  announcements: [
    {
      id: 1,
      title: '系统维护通知',
      category: 'system',
      content: '系统将于2024年1月25日凌晨2:00-4:00进行维护升级，期间可能影响部分功能使用。',
      publishTime: '2024-01-20 10:00:00',
      isRead: false,
      isFavorite: false,
      isImportant: true,
      attachments: []
    },
    {
      id: 2,
      title: '新功能上线：健康数据分析',
      category: 'feature',
      content: '我们很高兴地宣布，健康数据分析功能正式上线！您现在可以查看详细的健康趋势图表和个性化建议。',
      publishTime: '2024-01-18 14:30:00',
      isRead: true,
      isFavorite: true,
      isImportant: false,
      attachments: [
        { name: '功能介绍.pdf', url: '/files/feature-intro.pdf' }
      ]
    },
    {
      id: 3,
      title: '春节服务安排',
      category: 'service',
      content: '春节期间（2月10日-17日），我们的服务时间将有所调整。紧急服务24小时可用，常规服务时间为9:00-18:00。',
      publishTime: '2024-01-15 16:00:00',
      isRead: true,
      isFavorite: false,
      isImportant: false,
      attachments: []
    },
    {
      id: 4,
      title: '健康讲座：冬季养生知识',
      category: 'health',
      content: '本周六下午2点，我们将举办冬季养生知识讲座，欢迎大家参加。地点：社区活动中心。',
      publishTime: '2024-01-12 09:00:00',
      isRead: false,
      isFavorite: false,
      isImportant: false,
      attachments: []
    }
  ],
  
  // 公告分类
  categories: [
    { value: '', label: '全部' },
    { value: 'system', label: '系统通知' },
    { value: 'feature', label: '功能更新' },
    { value: 'service', label: '服务公告' },
    { value: 'health', label: '健康资讯' }
  ]
}

// ==================== 后台管理数据 ====================

/**
 * 后台管理数据
 * 包含病例记录、医疗档案、外出服务等管理功能数据
 */
export const mockAdminData = {
  // 病例记录
  medicalRecords: [
    {
      id: 'MR001',
      patientName: '张大爷',
      age: 68,
      gender: '男',
      diagnosis: '高血压、糖尿病',
      doctor: '李医生',
      createTime: '2024-01-15 10:30',
      status: 'active',
      treatments: [
        {
          id: 1,
          date: '2024-01-15',
          treatment: '开具降压药',
          doctor: '李医生',
          note: '血压控制良好，继续用药'
        }
      ]
    },
    {
      id: 'MR002',
      patientName: '李奶奶',
      age: 72,
      gender: '女',
      diagnosis: '骨质疏松',
      doctor: '王医生',
      createTime: '2024-01-18 14:20',
      status: 'active',
      treatments: []
    }
  ],
  
  // 病例档案
  medicalFiles: [
    {
      id: 'MF001',
      patientName: '张大爷',
      age: 68,
      gender: '男',
      category: 'chronic',
      diagnosis: '高血压、糖尿病',
      createDate: '2024-01-01',
      updateDate: '2024-01-20',
      documents: [
        { id: 1, name: '体检报告.pdf', type: 'report', uploadTime: '2024-01-15' },
        { id: 2, name: '化验单.jpg', type: 'test', uploadTime: '2024-01-18' }
      ],
      examinations: [
        { id: 1, date: '2024-01-15', type: '血常规', result: '正常', doctor: '李医生' }
      ]
    }
  ],
  
  // 外出服务申请
  outingApplications: [
    {
      id: 'OUT001',
      userName: '张大爷',
      phone: '13800138000',
      serviceType: 'housekeeping',
      appointmentTime: '2024-01-20 14:00',
      address: '北京市朝阳区xxx小区',
      price: 80,
      status: 'pending',
      createTime: '2024-01-15 10:30',
      description: '需要深度清洁服务，包括厨房和卫生间',
      specialRequirements: '请带专业清洁工具'
    }
  ],
  
  // 服务人员
  workers: [
    {
      id: 1,
      name: '张阿姨',
      phone: '13900139001',
      specialties: ['housekeeping'],
      rating: 4.9,
      status: 'available',
      completedServices: 156,
      experience: 5,
      introduction: '专业家政服务，经验丰富'
    }
  ]
}

// ==================== 工具函数 ====================

/**
 * 模拟API延迟
 * 用于模拟真实网络请求的延迟效果
 * @param {number} delay 延迟时间（毫秒），默认500ms
 * @returns {Promise} Promise对象
 */
export const mockDelay = (delay = 500) => {
  return new Promise(resolve => setTimeout(resolve, delay))
}

/**
 * 模拟API响应
 * 统一的API响应格式，包含状态码、消息和数据
 * @param {any} data 返回的数据内容
 * @param {number} delay 延迟时间（毫秒），默认500ms
 * @returns {Promise<Object>} 包含code、message、data的响应对象
 */
export const mockApiResponse = async (data, delay = 500) => {
  await mockDelay(delay)
  return {
    code: 200,
    message: 'success',
    data
  }
}

/**
 * 模拟分页数据处理
 * 对数组数据进行分页处理，返回分页信息和当前页数据
 * @param {Array} data 原始数据数组
 * @param {number} page 当前页码（从1开始）
 * @param {number} pageSize 每页显示的数据条数
 * @returns {Object} 包含list、total、page、pageSize、totalPages的分页对象
 */
export const mockPagination = (data, page = 1, pageSize = 10) => {
  const total = data.length
  const start = (page - 1) * pageSize
  const end = start + pageSize
  const list = data.slice(start, end)
  
  return {
    list,           // 当前页数据
    total,          // 总数据条数
    page,           // 当前页码
    pageSize,       // 每页大小
    totalPages: Math.ceil(total / pageSize)  // 总页数
  }
}